package com.jacen.fzxs.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jacen.fzxs.dao.IBaseDao;
import com.jacen.fzxs.dao.IWorkDao;
import com.jacen.fzxs.entity.WorkEntity;
import com.jacen.fzxs.service.IWorkService;
import com.jacen.fzxs.web.Pager;

@Service
public class WorkService extends BaseService<WorkEntity> implements IWorkService {
	
	@Resource
	private IWorkDao workDao;
	
	@Override
	public IBaseDao<WorkEntity> getDao() {
		// TODO Auto-generated method stub
		return workDao;
	}

	@Override
	public List<WorkEntity> getWorkByPosition(int position) {
		return workDao.getWorkByPosition(position);
	}

	@Override
	@Transactional(readOnly = true)
	public List<WorkEntity> getPage(Pager pager, Map<String, String> params) throws SQLException {
		pager.setTotalCount(getCount(params));
		return workDao.getPage( (pager.getCurPageNum() - 1) * pager.getPageSize(), pager.getPageSize(), params);
	}
	
	@Transactional(readOnly = true)
	public int getCount(Map<String, ? extends Object> params) throws SQLException {
		return workDao.getCount(params);
	}

}
